package com.guanzi.server.handler;

import com.guanzi.server.util.RespBean;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.security.SignatureException;

/**
 * @author Xg
 * @date 2021/6/4 10:50
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
//    @ExceptionHandler(value = { SignatureException.class })
//    @ResponseBody
//    public RespBean authorizationException(SignatureException e){
//        return RespBean.error( e.getMessage() );
//    }

    /**
     * 统一异常捕获
     * @param e
     * @return
     */
    @ExceptionHandler(value = { Exception.class })
    public RespBean Exception( Exception e ) {
        return RespBean.error( e.getMessage() );
    }
}

